﻿using System;
using QFramework.Fullstack;

namespace FangKuaiXiaoXiaoLe
{
    public interface IInputSystem
    {
        event Action<CodePrefab> OnCodeMouseDownEvent; 
        event Action<CodePrefab> OnCodeMouseEnterEvent;
        event Action OnCodeMouseUpEvent;

        void OnCodeMouseDown(CodePrefab codePrefabCompent);
        void OnCodeMouseEnter(CodePrefab codePrefabCompent);
        void OnCodeMouseUp();
    }

    public class InputSystem : IInputSystem
    {
        public event Action<CodePrefab> OnCodeMouseDownEvent;
        public event Action<CodePrefab> OnCodeMouseEnterEvent;
        public event Action OnCodeMouseUpEvent;

        public void OnCodeMouseDown(CodePrefab code)
        {
            Framework.CommandSystem.SendCommand(new MouseDownCommand(code));
        }

        public void OnCodeMouseEnter(CodePrefab code)
        {
            Framework.CommandSystem.SendCommand(new MouseEnterCommand(code));
            
        }
        
        public void OnCodeMouseUp()
        {
            Framework.CommandSystem.SendCommand(new MouseUpCommand());
        }
    }
}